#include "Common.h"
#include "SystemV/AppLibSystemV_Shm.hpp"

int main (int argc, char **args)
{
	SINT32 ShmId = -1;
	ULONG uRet = STAT_SUCCESS;
	CHAR *shmaddr = NULL;

	if (argc != 2)
	{
		printf("Usage: ./SystemV_Msg <Path>");
		return -1;
	}

	uRet = AppLibSystemV_ShmCreate(args[1], 1024, &ShmId);
	if (uRet != STAT_SUCCESS)
	{
		printf("[%s %d] AppLibSystemV_ShmCreate ret=%lu\n", __func__, __LINE__, uRet);
		return -2;
	}

	uRet = AppLibSystemV_ShmAttach(ShmId, (void **)&shmaddr);
	if (uRet != STAT_SUCCESS)
        {
                printf("[%s %d] AppLibSystemV_ShmAttach ret=%lu\n", __func__, __LINE__, uRet);
                return -3;
        }

	strcpy(shmaddr, "This is the new world");

	AppLibSystemV_ShmDetach(shmaddr);

	printf("quit");

	return 0;
}

